package db

import (
	"time"
)

type User struct {
	ID            int64     `gorm:"primaryKey"`
	Name          string    `gorm:"index:idx_name,unique;type:varchar(20)"`
	Password      string    `gorm:"type:varchar(20)"`
	FollowCount   int64     `gorm:"default:0"`
	FollowerCount int64     `gorm:"default:0"`
	CreatedAt     time.Time `gorm:"column:created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_at,omitempty"`
	UpdateAt      time.Time `gorm:"column:update_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP  on update current_timestamp" json:"update_at,omitempty"`
}

type Video struct {
	ID             int64  `gorm:"primaryKey"`
	UserId         int64  `gorm:"index:idx_user_id"`
	Title          string `gorm:"type:varchar(100)"`
	PlayUrl        string
	CoverUrl       string
	FavouriteCount int64     `gorm:"default:0"`
	CommentCount   int64     `gorm:"default:0"`
	CreatedAt      time.Time `gorm:"column:created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_at,omitempty"`
	UpdateAt       time.Time `gorm:"column:update_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP  on update current_timestamp" json:"update_at,omitempty"`
}

type Comment struct {
	ID        int64 `gorm:"primaryKey"`
	UserId    int64 `gorm:"type:bigint"`
	VideoId   int64 `gorm:"index:idx_video_id;type:bigint"`
	Content   string
	IsDel     bool
	CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_at,omitempty"`
	UpdateAt  time.Time `gorm:"column:update_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP  on update current_timestamp" json:"update_at,omitempty"`
}

type FavouriteRelation struct {
	ID        int64 `gorm:"primaryKey"`
	UserId    int64 `gorm:"index:idx_user_id;type:bigint"`
	VideoId   int64 `gorm:"index:idx_video_id;type:bigint"`
	IsDel     bool
	CreatedAt time.Time `gorm:"column:created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_at,omitempty"`
	UpdateAt  time.Time `gorm:"column:update_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP  on update current_timestamp" json:"update_at,omitempty"`
}

type FollowRelation struct {
	ID           int64 `gorm:"primaryKey"`
	UserId       int64 `gorm:"index:idx_user_id;type:bigint"`
	FollowUserId int64 `gorm:"index:idx_follow_user_id;type:bigint"`
	IsDel        bool
	CreatedAt    time.Time `gorm:"column:created_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP;<-:create" json:"created_at,omitempty"`
	UpdateAt     time.Time `gorm:"column:update_at;type:TIMESTAMP;default:CURRENT_TIMESTAMP  on update current_timestamp" json:"update_at,omitempty"`
}
